<template>
    <div style="padding:0px;">
    <el-form :model="dialogForm" :rules="rules" ref="dialogForm" :label-width="formLabelWidth">
      <el-card class="box-card">
        <div class="text item">
          <div slot="header" class="clearfix">
            <span style="line-height: 30px;">实名信息</span>
          </div>
          <el-form-item label="使用者手机号码">
            <el-input v-model="dialogForm.phone" auto-complete="off"  disabled></el-input>
          </el-form-item>
          <el-form-item label="使用者真实姓名">
            <el-input v-model="dialogForm.person" auto-complete="off"  disabled></el-input>
          </el-form-item>
          <el-form-item label="身份证号码">
            <el-input v-model="dialogForm.idCard" auto-complete="off"  disabled></el-input>
          </el-form-item>
           <el-form-item label="身份证照片">
            <qiniu  :qiniuImage="qiniuImage" :packJson="packJson2" :id="qiniuImage.id"></qiniu>
          </el-form-item>
           <el-form-item label="工作名片/在职证明">
            <qiniu  :qiniuImage="qiniuImage_1" :packJson="packJson2" :id="qiniuImage_1.id"></qiniu>
          </el-form-item>
          <div slot="header" class="clearfix">
            <span style="line-height: 30px;">实名认证</span>
          </div>
           <el-form-item label="经销商类别" prop="category" :rules="(this.dialogForm.status!=2||this.dialogForm.category=='')?rules.category:[{ required: false}]">
            <el-select v-model="dialogForm.category" placeholder="请选择经销商类别">
              <el-option label="请选择经销商类别" value="">
              </el-option>
              <el-option v-for="(item, index) in type" :label="item" :value="index-0" :key="index">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="业务员">
            <el-select v-model="dialogForm.businessSysUsersId" placeholder="请选择业务员">
              <el-option label="请选择业务员" value="">
              </el-option>
              <el-option v-for="(item,index) in yewuyuan" :label="item.realname" :value="item.id" :key="index">
              </el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="地推员">
            <el-select v-model="dialogForm.pushSysUsersId" placeholder="请选择地推员" >
              <el-option label="请选择地推员" value="">
              </el-option>
              <el-option v-for="(item,index) in ditui" :label="item.realname" :value="item.id" :key="index">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="资源员">
            <el-select v-model="dialogForm.resourceSysUsersId" placeholder="请选择资源员" >
              <el-option label="请选择资源员" value="">
              </el-option>
              <el-option v-for="(item,index) in ziyuan" :label="item.realname" :value="item.id" :key="index">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="实名认证信息"  prop="status" >
			    	<el-radio-group v-model="dialogForm.status" >
				      <el-radio :label="5" >通过</el-radio>
				      <el-radio :label="6" >不通过</el-radio>
				    </el-radio-group>
			    </el-form-item>
          <el-form-item label="实名认证备注" prop='realNameAuthenticationRemake'>
            <el-input type='textarea'  placeholder="限制100字" :maxlength="100" v-model="dialogForm.realNameAuthenticationRemake" auto-complete="off"></el-input>
          </el-form-item>
         
        </div>
      </el-card>
      <div style="text-align:right;margin-top:15px;">
        <el-button @click='returnBack' >返 回</el-button>
         <el-button @click="submitConfirmForm('dialogForm')">提交</el-button>
         
      </div>
    </el-form>
  </div>
</template>


<script>
  import qiniu from '@/views/qiniu/upload';
  import agentHttp from '@/utils/agentHttp.js';
  import {
    require,
    decimalFour,
    max100
  } from '@/utils/rules.js'
export default {
    mounted(){
        this.selectData();
    },
     components: {
      qiniu
    },
     props: ['oneselfProveFormVisible' ],
       data() {
      return {
        formLabelWidth: '170px',
        yewuyuan: {},
        ditui: {},
        ziyuan: {},
        type: {},
        //弹窗或者查看页面信息
        dialogForm: {
         
        },
        rules: {
          category: [require('经销商类别', {
            type: "number"
          })],
          status: [require('认证信息', {
            trigger: "change",
            type: "number"
          })],
          realNameAuthenticationRemake:[require('实名认证备注')]
        },
        qiniuImage:{
          id: Math.random() * 100,
          image_uri:[]
        },
        qiniuImage_1:{
          id: Math.random() * 100,
          image_uri:[]
		    },
      }
    },
    methods:{
         returnBack() {
        this.oneselfProveFormVisible.dialogFormVisible = false;
      },
      submitConfirmForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
              const params = {
                   "businessSysUsersId": this.dialogForm.businessSysUsersId,   //业务员
                    "category": this.dialogForm.category,            //经销商类别
                    "id": this.dialogForm.id,
                    "pushSysUsersId": this.dialogForm.pushSysUsersId,          // 地推人员
                    "realNameAuthenticationRemake": this.dialogForm.realNameAuthenticationRemake,           //实名认证备注 ,
                    "resourceSysUsersId": this.dialogForm.resourceSysUsersId,      //资源人员
                    "status": this.dialogForm.status                   //认证状态
              }
              agentHttp.putJson('adminApi/admin/dealer_ordinary/real_name_authentication',params).then((data)=>{
                         this.oneselfProveFormVisible.dialogFormVisible = false;
                          this.$message.success(data.data||"修改成功");
                          this.$emit('Refresh',null);
              }) 
          }
        });
      },
      selectData() {
        agentHttp.get('adminApi/admin/dealer_ordinary/select_dealer/' + this.oneselfProveFormVisible.id).then(
          (data) => {
            if (data.success) {
              this.dialogForm = data.data.dealer;
              this.type = data.data.type;
              this.ditui = data.data.ditui;
              this.ziyuan = data.data.ziyuan;
              this.yewuyuan = data.data.yewuyuan;
              this.qiniuImage.image_uri = this.dialogForm.idCardPic?this.dialogForm.idCardPic.split(',').notempty():[]
              this.qiniuImage_1.image_uri = this.dialogForm.workCardPic?this.dialogForm.workCardPic.split(',').notempty():[]
              
              this.dialogForm.status==5?this.dialogForm.status=this.dialogForm.status:this.dialogForm.status=6;
            }
          })
      },
    }
}
</script>
